The object of the game is to sink all the Computer's ships before it sinks all yours.

Both the Player and the Computer are given 5 ships to lay out on a 10x10 grid.

The ships are a straight line of squares (2 to 5 squares) forming a long rectangle.
The ships are laid vertically or horizontally on the 10x10 cell grid without overlap. 
Each square must be hit by the opponent in order to sink the ship.

The 5 ships are:
Carrier    - 5 squares to hit
Battleship - 4 squares to hit
Cruiser    - 3 squares to hit
Submarine  - 3 squares to hit
Destroyer  - 2 squares to hit

The game is started by each opponent laying out their ships secretly to the other.
You the Player must setup your ships on the right board.
They are setup in same order I listed above.

So the first ship to set up will be the Carrier that is 5 squares long.
First you will be prompted whether you want to lay it out horizontally or vertically, h or v ?

Then if horizontally is chosen, you click the cell where you want the left most square of the ship to go.
Like wise if vertical v was chosen, you click the board cell where you want the top most square to go.

If there is room on board to lay out all 5 across AND this ship does not overlap another, then the rest of the ship will be drawn in.
(Of course, the first ship can't overlap another but every other ship has that potential.)
If there is not room or the ship would overlap another, then you must start over with the prompt to lay the ship horizontally or vertically...

When you get all 5 of your ships laid out on the 10x10 grid on the left, the shooting match begins!

You will be prompted to click a cell on the left 10x10 board to guess where a Computer's ship might be.
If you hit a square on one of the Computers ships a red dot = hit appears at that cell.
If you miss all the Computers ships, a white dot will appear = miss

The Computer will then take a shot and your board will show a red or white dot according to the Computer's hit or miss.

Then it's your turn again. If you had a hit the last turn you will likely want to find the rest of the ship to sink it.
So click above, below, left or right of the hit = red dot.
A 2nd hit will tell you if the ship is laid out horizontally or vertically.
A 2nd hit would actually sink a Destroyer because it is only 2 squares long.

So you scout around the 10x10 board making random shots (or systematically cover the board with shots)
until you find a ship, sink it and go hunting for the next ship to sink until you get all 5.

Meanwhile the Computer is doing the same thing, so which ever opponent sinks all the ships first, wins!

Oh a caveat! 
It is possible to align the ships side by side or one end up next to another ship (as long as they don't overlap).
This makes it confusing as you might be hitting 2 different ships with your shots, so pay close attention to which ship is announced sunk
you might have more hits in the same area than how many it took to sink the ship.

https://en.wikipedia.org/wiki/Battleship_game

